/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lib;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author ismail
 */
public class util {

    lib.db db = new lib.db();

    public String getProjects() throws SQLException {
        String ret = "";
        db.openCon();



        ResultSet rs = db.getData("com_graph", "*", "1=1 order by id DESC");
        while (rs.next()) {

            ret += "<tr><td class='myprorow' id='row_" + rs.getString("id") + "'>"
                    + "" + rs.getString("title") + "<textarea class='opxml'  >" + rs.getString("data") + "</textarea></td><td><input type='button' id='" + rs.getString("id") + "' class='delbt' value='X'/></td></tr>";

        }
        db.closeCon();
        return ret;
    }

    public void saveProjects(String title, String data) throws SQLException {

        db.openCon();

        String[][] mydata = {{"title", "data"}, {title, data}};


        db.setInsert("com_graph", mydata);


    }

    public void deleteProjects(int id) throws SQLException {

 
        db.setDelete("com_graph", id);


    }

    public void updateProjects( String data, String id) throws SQLException {

        db.openCon();

        String[][] mydata = {{ "data"}, { data}};


        db.setUpdate("com_graph", mydata, Integer.parseInt(id));


    }
}
